#include <stdio.h>

void Printarr(int* arr, int len)
{
    int i = 0;
    for (i = 0; i < len; i++)
    {
        printf("%d ", arr[i]);
    }
    printf("\n");
}

void merge(int* nums1, int* nums2, int m, int n) 
{
    int len = m +n;
    int p1 = 0;
    int p2 = 0;
    int ps = 0;
    int sorted[6];

    if (n == 0)
        return;
        
    while (len--) 
    {
        if (nums1[p1] <= nums2[p2])
        {
            sorted[ps] = nums1[p1];
            ps++;
            p1++;
        }
        else
        {
            sorted[ps] = nums1[p2];
            ps++;
            p2++;
        }
    }

    for (int i = 0; i < m + n; i++)
    {
        nums1[i] = sorted[i];
    }

}

int main()
{
    int nums1[6] = {1, 2, 3, 0, 0, 0};
    int nums2[3] = {2, 5, 6};

    Printarr(nums1, 6);
    merge(nums1, nums2, 6, 3);
    Printarr(nums1, 6);
    

    return 0;
}